/**
 * 文章管理扩展
 */

var extendArticle = {
		targetW:0,
		targetH:0,
		targetL:0,
		targetT:0,
		init:function(id){
			this.targetW = $("#" + id).width();
			this.targetH = $("#" + id).height();
			this.targetL = $("#" + id).offset().left;
			this.targetT = $("#" + id).offset().top;
		},
		addTextInput : function(id){
				var inpu = document.createElement("input");
					inpu.setAttribute("type", "text");
					inpu.setAttribute("id", "_siteName" + id);
//					inpu.setAttribute("onkeyup","extendArticle.addDivPanel(this,'" + id +"','loadTcolunmSource(this,false)')");
//					inpu.setAttribute("onblur","extendArticle.delDivPanel('" +id+ "')");
					inpu.style.width = ($("#" + id).width() - 20 ) + "px";
					inpu.style.height =  ($("#" + id).height() - 3) + "px";
					inpu.style.display = "block";
					inpu.style.position = "absolute";
					inpu.style.left = $("#" + id).offset().left + "px";
					inpu.style.top = $("#" + id).offset().top + "px";
					inpu.style.zIndex = "1000";
				document.documentElement.appendChild(inpu);
		},
		addDivPanel : function(obj,method){
			if(obj.value.trim() != ''){
				$("#_dPanel").css('top',$(obj).offset().top + 20).css('left',$(obj).offset().left);
				$("#_dPanel").show();
				
				$("#_dPanel").find("span").each(function(){
					if($(this) != undefined)
						$(this).attr("onclick",method + "()");
				});
				
				$("#_dPanel").find("span:contains(" +obj.value+ ")").show();
				$("#_dPanel").find("span:not(:contains(" +obj.value+ "))").hide();
			}else{
				$("#_dPanel").hide();
			}
		},
		delDivPanel : function(){
			setTimeout(function(){
				$("#_dPanel").hide();
			},400);
		},
		loadSource : function(obj,id,method){
			var siteName = obj.value.trim();
			if(siteName != ''){
				$.ajax({
					url:'queryWebBySiteName',
					type:'post',
					dataType:'json',
					data:{'siteName':siteName},
					success:function(data){
						var html = '';
						if(data.length > 0){
							$.each(data,function(i,u){
								html += '<span class="site_result" id="'+u.id+'" onclick="' +method+ '">' +u.ftitle+ '</span><hr style="color:#ccc;"/>';
							});
						}
						$("#_dPanel" + id).html(html);
					},
					error:function(msg){
						_waiting._alert('数据加载出错');
					}
				});
			}
		}
};
